<template>
	<div style="display: flex;flex-direction: column;" class="otherPage partyBuildingLeads partyBuildingInNewsList">
		<Header :selected="2"></Header>
		<div class="bannerArea">
			<div class="banner" :style="bg_img? 'background:url('+bg_img+') no-repeat;background-size:cover;':''">

			</div>
		</div>
		<Navigation v-loading="loading" :items="breadcrumbItems" :menus="menus" :bgColor="bgColor" :checked="1">
		</Navigation>
		<div class="content">
			<div class="content_bg">
				<el-row>
					<el-col :span="24" class="newArea">
						<div class="news-list">
							<el-row :gutter="6" v-for="(item, index) in newsList" :key="index" class="news-item"
								:class="{ 'hover': hoverIndex === index }" @mouseover="hoverIndex = index"
								@mouseleave="hoverIndex = -1">
								<el-col :xs="5" :sm="5" :md="3" :lg="3">
									<div class="date">
										<div class="day">{{ formatDate(item.createTime, 'DD') }}</div>
										<div class="month-year">{{item.createTime?item.createTime.substring(0,7):''}}
										</div>
									</div>
								</el-col>
								<el-col :xs="15" :sm="15" :md="18" :lg="18" class="newcontent">
									<div class="newcontentcontainer">
										<div class="title" @click="goToDetail(item.id)">{{ item.title }}</div>
										<p v-html="item.content" class="description"> </p>

									</div>
								</el-col>
								<el-col :xs="4" :sm="4" :md="3" :lg="3" class="newcontentMoreArea">
									<div class="moreInfoBtn" @click="goToDetail(item.id)">{{$t("more")}} <i
											class="el-icon-d-arrow-right"></i></div>
								</el-col>
							</el-row>
						</div>
					</el-col>
				</el-row>
				<el-row :gutter="24" type="flex" class="paginationArea">
					<el-pagination background :current-page.sync="currentPage" :page-size="pageSize"
						:layout="isShowJumper?'prev, pager, next,total,jumper ':'prev, next,total' "  :total="total" :prev-text="$t('previousPage')"
						:next-text="$t('nextPage')" @current-change="handleCurrentChange" />
				</el-row>
			</div>
		</div>
		<Footer></Footer>
	</div>
</template>

<script>
	import Header from '../../components/common/header/Header.vue'
	import Navigation from '../../components/common/navigation/Navigation.vue'
	import Footer from '../../components/common/footer/Footer.vue'

	import {
		partyBuildingLeads
	} from '../../utils/menu.js'
	import {
		getStore,
		setStore
	} from '../../utils/tools.js';
	export default {
		components: {
			Header,
			Navigation,
			Footer,

		},
		data() {
			return {
				isShowJumper: true,
				loading: true,
				bg_img: '', //头部banner，默认值已绑定，有背景自动切换
				bgColor: "white", //white/red
				pageSize: 10,
				total: 0,
				currentPage: 1,
				menus: partyBuildingLeads,
				breadcrumbItems: [{
						//首页
						label: this.$t('home'),
						to: '/home'
					},
					{
						//党建引领
						label: this.$t('partyBuildingLeads'),
						to: '/partyBuildingLeads'
					},
					{
						//党建资讯
						label: this.$t('partyBuildingInformation'),
						to: '/partyBuildingInformation'
					}
				],
				newsList: [],
				hoverIndex: -1
			};
		},
		computed: {},
		created() {
			this.getPartyInfoPage();
		},
		mounted() {
			this.getPartyInfoTopImage();
			if(this.$request.checkIsMobile()){
				this.isShowJumper = false;
			}
		},
		methods: {
			/**
			 * 获取banner图片
			 */
			getPartyInfoTopImage() {
				let params = {};
				let that = this;
				that.$request.getPartyInfoTopImage(params).then(res => {
					if (res && res.data) {
						that.bg_img = res.data.fileUrl;
					}
				}).catch((error) => {
					console.log(error);
				});
			},
			formatDate(date, format) {
				const dateObj = new Date(date);
				const year = dateObj.getFullYear();
				const month = String(dateObj.getMonth() + 1).padStart(2, '0');
				const day = String(dateObj.getDate()).padStart(2, '0');

				// 根据传入的格式进行处理
				if (format === 'yyyy-MM') {
					return `${year}-${month}`;
				} else if (format === 'DD') {
					return day;
				}
				return date;
			},

			/**
			 * 获取新闻列表
			 */
			getPartyInfoPage() {
				let partyListPage = parseInt(getStore("partyListPage"));
				this.currentPage = partyListPage > 0 ? partyListPage : this.currentPage;
				//	alert(this.currentPage)
				let params = {
					"pageNum": this.currentPage,
					"pageSize": this.pageSize
				};

				let that = this;
				that.$request.getPartyInfoPage(params).then(res => {
					if (res && res.data) {
						this.newsList = res.data.records;
						this.total = res.data.total;
						this.pageSize = res.data.size;
						this.currentPage = res.data.current;
					}

					this.loading = false;
				}).catch((error) => {
					console.log(error);
				});

			},
			handleCurrentChange(currentPage) {
				//alert(currentPage);
				this.currentPage = currentPage;
				setStore("partyListPage", this.currentPage);
				this.getPartyInfoPage();
			},
			//////跳转详情页面
			goToDetail(id) {
				this.$router.push({
					name: this.$t("partyBuildingInNewsDetail"),
					query: {
						id: id,
					}
				});
			},

		}
	}
</script>

<style scoped>
	@import url("../../components/common/css/partyBuildingLeads/partyBuildingLeads.css");

	.partyBuildingInNewsList .newArea {
		height: auto;
	}

	.partyBuildingInNewsList .paginationArea {
		height: 70px;
		line-height: 70px;
		justify-content: center;
		padding-top: 20px;
	}


	.partyBuildingInNewsList .title {
		padding-left: 10px;
		float: left;
		height: 6vh;
		line-height: 4vh;
		width: 100%;
		font-size: 20px;
		position: relative;
		white-space: nowrap;
		text-overflow: ellipsis;
		overflow: hidden;
	}

	.partyBuildingInNewsList .newsContent {
		padding-left: 10px;
		float: left;
		height: 7vh;
		line-height: 3.5vh;
		width: 100%;
		font-size: 1em;
		/* 	 margin-top:1vh; */
		opacity: 0.8;
		display: -webkit-box;
		-webkit-line-clamp: 2;
		-webkit-box-orient: vertical;
		overflow: hidden;
		font-size: 14px !important;
	}

	/* 列表样式 */
	.partyBuildingInNewsList .moreInfoBtn {
		width: 100%;
		height: 14vh;
		line-height: 12vh;
		align-items: center;
		text-align: center;
		color: #0484D7;
		font-size: 16px;
		padding: 0px;
	}

	/* 	.partyBuildingInNewsList .moreInfoBtn:hover {
		background-color: #0396f0;
		color: #0396f0;
	} */


	.partyBuildingInNewsList .news-list .news-item {
		height: 16vh;
		/* 	margin-bottom: 1vh ; */
		border-bottom: 1px solid #E8E6E5;
	}

	.partyBuildingInNewsList .news-list .date {
		border-bottom: 2px solid #E8E6E5;
		height: 12vh;
		background: #EDEDED;
		margin-top: 2vh;
		width: 80%;
	}

	.partyBuildingInNewsList .news-list .title {
		font-size: 1.5rem;
		font-weight: 530;
		color: #333333;
		height: 6vh;
		line-height: 6vh;
		padding: 0px;
		align-items: center;
		white-space: nowrap;
		overflow: hidden;
		text-overflow: ellipsis;
	}

	.partyBuildingInNewsList .news-list .number-of-views {
		font-size: 14px;
		font-weight: 400;
		color: #999999;
		height: 5vh;
		line-height: 5vh;
		align-items: center;
	}

	.partyBuildingInNewsList .news-list .description {
		font-size: 14px;
		font-weight: 400;
		color: #666666;
		height: 6vh;
		line-height: 3vh;
		padding: 0px;
		align-items: center;
		overflow: hidden;
	}

	.partyBuildingInNewsList .news-list .day {
		text-align: center;
		font-size: 2em;
		padding-top: 2vh;
		height: 7vh;
		font-weight: 400;
		color: #0484D7;
		/* padding-left: 15px; */
	}

	.partyBuildingInNewsList .dateText {
		height: 4vh;
		line-height: 4vh;
		align-items: center;
		text-align: left;
		color: #777777;
		font-size: 1.2em;
		/* padding-left: 15px; */
		opacity: 0.8;
	}

	.partyBuildingInNewsList .news-list .month-year {
		text-align: center;
		font-size: 1.2em;
		/* padding-left: 15px; */
		opacity: 0.8;
		color: #777777;
	}

	.partyBuildingInNewsList .btn-next span {
		min-width: 50px !important;
	}

	.el-pagination span:not([class*=suffix]) {
		display: inline-block;
		font-size: 13px;
		min-width: 50px !important;
		height: 28px;
		line-height: 28px;
		vertical-align: top;
		-webkit-box-sizing: border-box;
		box-sizing: border-box;
	}

	.news-item {
		margin-bottom: 20px;
		cursor: pointer;
		overflow: hidden;
		transition: transform 0.3s ease;
		/* 添加过渡效果 */
	}

	.partyBuildingInNewsList .news-item:hover {
		transform: scale(0.98)
	}

	.partyBuildingInNewsList .news-item:hover .title {
		color: #0484D7;
	}

	.partyBuildingInNewsList .news-item:hover .date {
		background-color: #0484D7;
		
	}

	.partyBuildingInNewsList .news-item:hover .day,
	.partyBuildingInNewsList .news-item:hover .month-year,
	.partyBuildingInNewsList .news-item:hover .dateText {
		color: #FFF;
		opacity: 1;
	}

	.partyBuildingInNewsList .news-list .newcontent {
		margin-top: 1vh;
	}

	.partyBuildingInNewsList .news-list .newcontent .newcontentcontainer {
		display: flex;
		flex-direction: column;
		background-color: #FFF;
	}

	::v-deep .el-pagination span:not([class*=suffix]) {
		display: inline-block;
		font-size: 13px;
		min-width: 50px;
		height: 28px;
		line-height: 28px;
		vertical-align: top;
		-webkit-box-sizing: border-box;
		box-sizing: border-box;
	}


	.partyBuildingLeads .content {
		padding: 0;
	}

	.content_bg {
		margin: 0px auto;
		padding: 50px;

	}

	@media (min-width: 2560px) {
		.content_bg {
			width: calc(2560px * 0.8);
		}
	}

	@media (max-width: 2560px) {
		.content_bg {
			width: calc(2560px * 0.8);
		}
	}

	@media (max-width: 2320px) {
		.content_bg {
			width: calc(2320px * 0.8);
		}
	}

	@media (max-width: 2120px) {
		.content_bg {
			width: calc(2120px * 0.8);
		}
	}

	@media (max-width: 1920px) {
		.content_bg {
			width: calc(1920px * 0.8);
		}

		.companyCultureImgArea {
			width: 60%;
		}

		.companyCultureContent {}

	}

	@media (max-width: 1720px) {


		.content_bg {
			width: calc(1720px * 0.8);
		}
	}

	@media (max-width: 1520px) {
		.content_bg {
			width: calc(1520px * 0.8);
		}
	}

	@media (max-width: 1366px) {
		.content_bg {
			width: calc(1366px * 0.8);
		}
	}

	@media (max-width: 1120px) {
		.content_bg {
			width: 100%
		}
	}

	@media (max-width: 1024px) {}

	@media (max-width: 900px) {}


	@media (max-width:768px) {
		.partyBuildingInNewsList .news-list .news-item{
			height:80px ;
		}
		.partyBuildingInformation .news-list .news-item{
			height:80px ;
		}
		 
		.partyBuildingInNewsList .news-list .date{
			height: 100%;
			width: 100%;
			margin-top:0px;
			opacity:0.8;
		}
		.partyBuildingInNewsList .news-list .newcontent {
			padding: 0px 5px;
			margin-top: 0;
		}

		.partyBuildingInNewsList .news-list .newcontent .title {

			height: 30px;
			line-height: 30px;
			font-size: 16px;
			
		}

		.partyBuildingInNewsList .newcontent .description {

			height: 40px;
			line-height: 22px;
			font-size: 12px;
		}

		.partyBuildingInNewsList .news-list .day {
			height:30px;
			padding-top: 10px;
			line-height: 30px;
			font-size: 30px;
			color: #fff;
		}

		.partyBuildingInNewsList .news-item .date {
			color: #ffffff;
			background-color: #0484D7;
		}

		.partyBuildingInNewsList .news-list .date {
			
		}

		.partyBuildingInNewsList .news-item .newcontent .title {
			color: #0484D7;
			font-size: 16px;
			font-weight:530;
		}



		.partyBuildingInNewsList .slideTitle {
			font-size: 14px;
		}

		.partyBuildingLeads .news-list .month-year {}

		.partyBuildingInNewsList .news-list .month-year {
			font-size: 12px;
			height: 30px;
			line-height: 30px;
			color: #fff;
			opacity:1;
		}

		.partyBuildingInNewsList .slideTitle {
			font-size: 12px;
			padding: 0px 26% 0px 10px;
		}

		.partyBuildingInNewsList .moreInfoBtn {
			font-size: 12px;
			height: 80px;
			line-height: 80px;
		}
	}
</style>